import React from "react";
import Todo from "./todo/Todo";
import List from "./list/List";
import { useState } from "react";
import './todulist.scss'

const Todolist =()=> {
  const [list,setlist] = useState({
    list:[
      {title:'宝马',date:'1978',priority:'1'},
      {title:'凯美瑞',date:'1999',priority:'2'},
      {title:'夏利',date:'2003',priority:'3'},
      {title:'奔驰',date:'1978',priority:'1'},
      {title:'迈腾',date:'1999',priority:'2'},
      {title:'桑塔纳',date:'2003',priority:'3'},
      {title:'帕沙特',date:'1999',priority:'2'},
      {title:'奥迪',date:'1978',priority:'1'},
    ]
  })

  //添加
  let todolist = (msg)=>{
    console.log(msg);//子组件传来的数据
    let Lists = list.list
    if(Lists.length===0){
       Lists.push(msg)//子组件的内容push到Lists里面  
    } else {
      //实现优先级
      for(let i = 0;i<Lists.length;i++){
          
      }
    }
    
  }

    return ( 
      <div className="warpper">
        <div className="todo">
          <h3>todolist</h3>
            <Todo todolist={todolist}/>
            <List list={list}/>
        </div>
      </div>
     );
}
 
export default Todolist;